package com.peanut.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.peanut.domain.bo.TabCarBrandBO;
import com.peanut.domain.po.TabCarBrandPO;
import com.peanut.service.TabCarBrandService;
import com.peanut.mapper.TabCarBrandMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
* @author 张涛
* @description 针对表【tab_car_brand】的数据库操作Service实现
* @createDate 2022-05-26 15:15:48
*/
@Service
public class TabCarBrandServiceImpl extends ServiceImpl<TabCarBrandMapper, TabCarBrandPO>
    implements TabCarBrandService{

    @Resource
    private TabCarBrandMapper brandMapper;

    @Override
    public int addBrand(TabCarBrandBO bo) {
        TabCarBrandPO brand = new TabCarBrandPO();
        BeanUtils.copyProperties(bo,brand);
        return brandMapper.insert(brand);
    }

    @Override
    public Page<TabCarBrandPO> findAll(Integer pageNumber, Integer pageSize) {
        Page<TabCarBrandPO> page = new Page<>(pageNumber,pageSize);
        Page<TabCarBrandPO> brand = brandMapper.selectPage(page, null);
        return brand;
    }

    @Override
    public int updateBrand(TabCarBrandBO bo) {
        TabCarBrandPO brand = new TabCarBrandPO();
        BeanUtils.copyProperties(bo,brand);
        return brandMapper.updateById(brand);
    }

    @Override
    public int deleteBrand(Long carBrandId) {
        return brandMapper.deleteById(carBrandId);
    }
}




